const webpack = require("webpack");
const WebpackDevServer = require('webpack-dev-server')
const path = require('path')
const webpackConfig = require("./webpack.config.js");

webpackConfig.entry.app.unshift("webpack-dev-server/client?http://localhost:8080/", "webpack/hot/dev-server");
webpackConfig.output.path = path.resolve(__dirname,webpackConfig.output.path);
webpackConfig.plugins.push(
    new webpack.HotModuleReplacementPlugin(),
    new webpack.WatchIgnorePlugin(['node_modules'])
)
var compile = webpack(webpackConfig);

var server = new WebpackDevServer(compile,{
    hot:true,
    progress:true,
    quiet:false,
    inline:true,
    noInfo:false,
    filename: webpackConfig.output.filename,
    watchOptions: {
        aggregateTimeout: 300,
        poll: 1000
    },
    stats: {
        colors: true
    },
})

let port = 8080;

server.listen(port,"localhost",function(error){
    if(error){
        console.log("error:");
        console.log(error);
    }

    console.log("start listen on localhost:" + port);
})

